
; You may customize this and other start-up templates; 
; The location of this template is c:\emu8086\inc\0_com_template.txt

org 100h

MOV AX, 0B00H
MOV DS, AX
MOV AH, 00H

MOV AL, 00H
MOV [SI], AL   ; N
MOV AL, 00H
MOV [SI+1], AL ; T
MOV AL, 00H
MOV [SI+2], AL ; T2
MOV AL, 00H
MOV [SI+3], AL ; 2T+A
MOV AL, 00H
MOV [SI+4], AL ; TT2
MOV AL, 10H
MOV [SI+5], AL ; TOP
MOV AL, 00H
MOV [SI+6], AL ; DOWN
MOV AL, 10H
MOV [SI+7], AL ; 16
MOV AL, 08H
MOV [SI+8], AL ; 8
MOV AL, 08H
MOV [SI+9], AL ; 8
MOV AL, 00H
MOV [SI+10], AL; 0
MOV AL, 01H
MOV [SI+11], AL; 1
MOV AL, 0FFH
MOV [SI+12], AL; FFH
MOV AL, 80H
MOV [SI+13], AL; 80H

MOV AL, [SI]
XOR AL, [SI+12]
ADD AL, [SI+11]
MOV [SI], AL


C1: MOV AL, [SI+9]
    ADD AL, [SI+1]
    ADD AL, [SI+1]
    MOV [SI+3], AL
    
    MOV AL, [SI+2]
    MOV [SI+4], AL
    L1: MOV AL, [SI+4]
        ADD AL, [SI+3]
        MOV [SI+4], AL
        MOV AL, [SI+7]
        ADD AL, [SI+12]
        MOV [SI+7], AL
        JZ  D7
        AND AL, [SI+11]
        JZ  D7
        MOV AL, [SI+8]
        ADD AL, [SI+12]
        MOV [SI+8], AL
        D7: MOV AL, [SI+7]
        XOR AL, [SI+9]
        JZ D0
        MOV CX, 2
        LOOP L1
D0: MOV AL, [SI+8]
    MOV [SI+9], AL
    MOV AL, [SI]
    ADD AL, [SI+4]
    JZ  D8
    AND AL, [SI+13]
    JZ  D2
    MOV AL, [SI+1]
    ADD AL, [SI+7]
    MOV [SI+6], AL
    MOV [SI+1], AL
    MOV AL, [SI+4]
    MOV [SI+2], AL  
    XOR CX, CX
    JZ  D3  
    D2: MOV AL, [SI+1]
        ADD AL, [SI+7]
        MOV [SI+5], AL  
    D3: MOV AL, [SI+7]
    XOR AL, [SI+11]
    JZ  D1     
    MOV CX, 2
    LOOP C1

D8: MOV DH, [SI+1]
    ADD DH, [SI+7]
    MOV DL, DH
    XOR CX, CX
    JZ  ENDD
    
D1: MOV DH, [SI+5]
    MOV DL, [SI+6]
    
ENDD: MOV AL, [SI]
      SUB AL, 1
      XOR AL, [SI+12]    
ret




